import { FormSchema } from "/@/components/Table"
import { isRoleExist, listMenuScheme } from "./fileRecord.api"
import { DescItem } from "/@/components/Description/index"
import { render } from "/@/utils/common/renderUtils"

export const columns = [
  {
    title: "业务类型",
    dataIndex: "bizType",
    width: 100,
  },
  {
    title: "存储器",
    dataIndex: "storageType",
    customRender: ({ text }) => {
      if (!text) {
        return
      }
      return render.renderTag(render.renderDict(text, "file_storage_type"), "green")
    },
    width: 100,
  },
  {
    title: "原始名称",
    dataIndex: "originalName",
    width: 150,
  },
  {
    title: "新名称",
    dataIndex: "newName",
    width: 150,
  },
  {
    title: "文件类型",
    dataIndex: "fileType",
    width: 150,
  },
  {
    title: "大小",
    dataIndex: "fileSize",
    customRender: ({ text }) => {
      return render.renderSpan(text + " KB")
    },
    width: 80,
  },
  {
    title: "创建时间",
    dataIndex: "createdAt",
    width: 160,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "bizType",
    label: "业务类型",
    component: "Input",
    colProps: { span: 6 },
  },
  {
    field: "originalName",
    label: "文件原始名称",
    component: "Input",
    colProps: { span: 6 },
  },
]

export const formDetailSchema: DescItem[] = [
  {
    field: "bizType",
    label: "业务类型",
  },
  {
    field: "bucketName",
    label: "存储桶",
  },
  {
    field: "storageType",
    label: "存储器",
    render: (curVal, data) => {
      return render.renderTag(render.renderDict(curVal, "file_storage_type"), "green")
    },
  },
  {
    field: "originalName",
    label: "文件原始名称",
  },
  {
    label: "新文件名",
    labelMinWidth: 50,
    field: "newName",
  },
  {
    field: "fileType",
    label: "文件类型",
  },
  {
    field: "fileSize",
    label: "文件大小",
    render: (curVal, data) => {
      return render.renderTag(curVal + " KB", "green")
    },
  },
  {
    field: "filePath",
    label: "存储绝对路径",
  },
  {
    field: "createdAt",
    label: "创建时间",
  },
  {
    field: "createdBy",
    label: "创建者",
  },
]
